package com.codeoss.framework.webide.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.codeoss.framework.webide.request.PageWizardDialogRequest;
import com.codeoss.framework.webide.response.PageWizardDialogResponse;
import com.codeoss.framework.webide.service.IPageWizardDialogService;

@Controller
@RequestMapping("webide/pagewizarddialog")
public class PageWizardDialogController {
	@Autowired
	private IPageWizardDialogService pageWizardDialogService;

	@RequestMapping(value = "onFinish", method = RequestMethod.POST)
	@ResponseBody
	public PageWizardDialogResponse onFinish(@RequestBody PageWizardDialogRequest pageWizardDialogRequest) {
		PageWizardDialogResponse pageWizardDialogResponse = pageWizardDialogService.onFinish(pageWizardDialogRequest);
		return pageWizardDialogResponse;
	}
	
	@RequestMapping(value = "initDataSourceSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public PageWizardDialogResponse initDataSourceSelectPage() {
		PageWizardDialogResponse pageWizardDialogResponse = pageWizardDialogService.initDataSourceSelectPage();
		return pageWizardDialogResponse;
	}
	
	@RequestMapping(value = "initTableFieldSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public PageWizardDialogResponse initTableFieldSelectPage(@RequestParam("tableName")String tableName) {
		PageWizardDialogResponse pageWizardDialogResponse = pageWizardDialogService.initTableFieldSelectPage(tableName);
		return pageWizardDialogResponse;
	}
	
	@RequestMapping(value = "initUReportSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public PageWizardDialogResponse initUReportSelectPage() {
		PageWizardDialogResponse pageWizardDialogResponse = pageWizardDialogService.initUReportSelectPage();
		return pageWizardDialogResponse;
	}
	
	@RequestMapping(value = "initModuleTypeSelectPage", method = RequestMethod.GET)
	@ResponseBody
	public PageWizardDialogResponse initModuleTypeSelectPage() {
		PageWizardDialogResponse pageWizardDialogResponse = pageWizardDialogService.initModuleTypeSelectPage();
		return pageWizardDialogResponse;
	}
}
